var parsePosition = require('./parsePosition.js');
//批量解析位置
var parseBatchPosition = function(b,head){
    // 批量解析位置暂不解析数据
    var res = {
    	gpsMsgNum: code.bytes2int2(b.slice(0,2)),
    	gpstype: b[2],
    	batchGpsInfo: []
    };

    var data = b.slice(3);
    for(var i=0;i<res.gpsMsgNum;i++){
    	var msglength = code.bytes2int2(data.slice(0,2));
    	var gpsinfo = parsePosition.parsePosition(data.slice(2,2+msglength));
    	res.batchGpsInfo[i] = gpsinfo;
    	data = data.slice(2+msglength);
    }

    var response = code.makeMessage(
        [0x80,0x01],
        code.str2Bcd(head.TerminalPhoneNum),
        code.getSerialNumber(),
        [].concat(
            code.int2bytes2(head.MsgNumber),
            [0x07,0x04],
            0x00
        )
    );
    return response;
};

module.exports = {
    parseBatchPosition:parseBatchPosition
}